package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.dto.QuestionFormDTO;
import com.tianji.learning.domain.query.QuestionPageQuery;
import com.tianji.learning.domain.vo.QuestionVO;
import com.tianji.learning.service.IInteractionQuestionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/questions")
@Api(tags = "互动问题相关接口")
public class InteractionQuestionController {
    @Autowired
    private IInteractionQuestionService questionService;

    @ApiOperation("发布问题")
    @PostMapping
    public void saveQuestion(@RequestBody QuestionFormDTO questionFormDTO){
        questionService.saveQuestion(questionFormDTO);
    }

    @ApiOperation("用户端-分页查询数据")
    @GetMapping("/page")
    public PageDTO<QuestionVO> userQuestionPage(QuestionPageQuery query){
        return questionService.userQuestionPage(query);
    }

    @ApiOperation("用户端-根据id查询问题详情")
    @GetMapping("/{id}")
    public QuestionVO findQuestionById(@PathVariable("id") Long id){
        return questionService.findQuestionById(id);
    }


}
